<template>
  <div class="innerPage" v-if="falg">
    <div class="inner-img">
      <div class="img-bg" :style="'background-image:url(' + Contentlist.cover + ')'"
        v-if="VideoIndexOf(Contentlist.cover ? Contentlist.cover : Contentlist.files)">
      </div>
      <vueVideo class="img-bg" :collection="Contentlist.files" v-else />
    </div>
    <div class="bottom-bg"></div>
    <van-row justify="center">
      <van-col span="24" class="inner-title">
        <h1>{{ Contentlist.name }}</h1>
        <h1>{{ Contentlist.code }}</h1>
      </van-col>
    </van-row>
    <van-cell-group inset>
      <van-field v-model="formData.name" placeholder="请输入好友账号" />
    </van-cell-group>
    <div class="tips">
      <p>1.填写好友注册账号即可直接赠与</p>
      <p>2.若好友24小时内未接收转赠，礼物将会退回</p>
      <p>3.转赠需支付手续费：{{ formData.price }}元</p>
    </div>
    <van-button type="primary" block class="linearbg" @click="submit">确定</van-button>
  </div>
</template>
<script>
import { defineComponent, ref, reactive, toRefs, onMounted } from 'vue'
import Clipboard from 'clipboard';
import useClipboard from 'vue-clipboard3'
import { Toast } from "vant";
import { useRouter } from "vue-router"
import { conversion, conversionfee, collectionInfo } from "@/api/public";
import { VideoIndexOf } from "@/utils/phone";
import vueVideo from "@/components/video.vue";
export default {
  name: "",
  components: { vueVideo },
  setup(props) {
    const router = useRouter()
    const falg = ref(false)
    const Contentlist = ref({})
    const formData = reactive({
      name: '',
      price: ""
    })
    onMounted(async () => {
      onload()
    })
    const onload = async () => {
      Contentlist.value.image = router.currentRoute.value.query.img
      Contentlist.value.name = router.currentRoute.value.query.name
      Contentlist.value.code = router.currentRoute.value.query.code
      Contentlist.value.id = router.currentRoute.value.query.id
      const parmars = {
        userCollectionId: router.currentRoute.value.query.id
      }
      const e = await collectionInfo(parmars)
      Contentlist.value = e.data.data
      const res = await conversionfee()
      formData.price = res.data.data
      falg.value = true
    }
    const submit = async () => {
      const data = {
        userCollectionId: router.currentRoute.value.query.id,
        mobile: formData.name
      }
      if (!formData.name) {
        return Toast('请输入好友账号')
      }
      const res = await conversion(data)
      if (res.data.success) {
        router.push({
          path: '/Giftsued'
        })
      } else {
        return Toast(res.data.message)
      }
    }
    return {
      Contentlist, formData, submit, VideoIndexOf, falg, onload
    }
  }
}
</script>
<style lang="less" scoped>
.innerPage {
  padding-bottom: 148px;

  .inner-img {
    overflow: hidden;
    width: 648px;
    height: 648px;
    background: linear-gradient(0deg, #161718, #4b4c4d);
    border: 2px solid #ffffff;
    border-radius: 80px;
    margin: 80px auto 20px;

    .img-bg {
      background-repeat: no-repeat;
      width: 648px;
      height: 648px;
      // height: 445px;
      background-size: cover;
      margin: 0px auto;
      position: relative;
      background-position: center;
    }
  }

  .bottom-bg {
    background-repeat: no-repeat;
    background: url('../../assets/image/bottom.png');
    width: 660px;
    height: 220px;
    background-size: cover;
    margin: 0px auto;
  }

  .inner-title {
    text-align: center;

    h1 {
      font-size: 46px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #f8f8f8;
      line-height: 103px;
      margin: 0px;
    }

    p {
      font-size: 36px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #f8f8f8;
      background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
  }

  &:deep(.van-cell-group) {
    width: 708px;
    height: 98px;
    background: #282a2c;
    border: 1px solid #999;
    box-shadow: 0px 2px 16px 0px rgba(0, 0, 0, 1);
    border-radius: 49px;
    margin: 50px auto 0px;
  }

  &:deep(.van-field) {
    background: transparent;
    font-weight: 300;
    color: #b9c4c7;
    font-size: 30px;
  }

  .tips {
    padding: 30px 40px;

    p {
      font-weight: 300;
      color: #ffffff;
      line-height: 46px;
      font-size: 26px;
    }
  }

  .linearbg {
    margin: 100px 35px 30px;
    width: 680px;
    height: 88px;
    background: linear-gradient(-90deg, #37dc6d, #34d1f9);
    border-radius: 44px;
    border: none;
    font-size: 32px;
    font-weight: bold;
    color: #ffffff;
    line-height: 70px;
  }
}
</style>